<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>模板语法</title>
  <script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
  <style>
    .box {
      border-bottom: 1px solid red;
      margin-bottom: 20px;
      padding-bottom: 5px;
    }
    .tip {
      color: red;
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="box">
      <h3>文本绑定</h3>
      <p v-once>这个是不会改变的：{{ msg }}</p>
      <p>这个是会改变的：{{ msg }}</p>
      <button v-on:click="change">改变:v-on</button>
      <button @click="change">改变:@</button>
    </div>

    <div class="box">
      <h3>原始HTML</h3>
      <p><span class="tip">没用指令</span> {{ vhtml }}</p>
      <p><span class="tip">用指令</span> <span v-html="vhtml"></span></p>
    </div>

    <div class="box">
      <h3>特性(标签属性)</h3>
      <span v-bind:id="vid">标签</span>
    </div>

    <div class="box">
      <h3>指令</h3>
      <p v-if="seen">被指令控制了</p>
    </div>

  </div>

  <script>
    var vue = new Vue({
      el: "#app",
      data: {
        msg: " 范玉正 你好",
        vhtml: 'Using mustaches: <span style="color: red">This should be red.</span>',
        vid: "spanid",
        seen: true
      },
      methods: {
        change: function () {
          this.msg = "hello, world"
        }
      }
    })
  </script>
</body>
</html>